<?php

$series = $module->message;

?>

<div id='message-series'>
  <div class='title-image'>
    <?php if( $series->hasBumper()) : ?>
    <a href='<?= $series->getBumper() ?>' title='<?= $series->getTitle() ?>' class='title' <?= $series->tracking ?>>
      <span class='play'></span>
    <?php endif ?>
      <img src='<?= $series->getCoverImage() ?>' alt='<?= $series->getTitle() ?>'>
    <?php if( $series->hasBumper() ) : ?>
    </a>
    <?php endif ?>
  </div>

  <div class='media-table'>
    <div class='title-text'>
      <?php if( $series->hasTitle() ) : ?><h2><?= $series->getTitle() ?></h2><?php endif ?>
      <?php if( $series->isCurrent() ) : ?><h3>Current Series</h3><?php endif ?>
    </div>

    <table border='0'>
      <tr>
        <th>Title</th>
        <th>Media</th>
      </tr>
      <?php if( $series->hasMessages() ): ?>
      <?php foreach( $series->getMessages() as $m ): ?>
      <tr class='message-details'>
        <td class='info'><span class='title'><?= $m->getTitle() ?></span><br>
          by <?= $m->getSpeaker() ?>
          <time><?= $m->getDate() ?></time>
        </td>
        <td class='media'>
          <ul class='media-tools'>
            <?php if( $m->hasVideo()) : ?>
            <?php $tracking = sprintf($series->tracking, $series->getTitle() . $m->getShortDate() .  "/video.html"); ?>
            <li class="watch">
              <a href='<?= $m->getVideo() ?>' title='watch <?= $m->getTitle() ?>' <?= $tracking ?> target="_blank">Watch</a>
            </li>
            <?php endif ?>
            <?php if( $m->hasAudio()) : ?>
            <?php $tracking = sprintf($series->tracking, $series->getTitle() . $m->getShortDate() .  "/audio.html"); ?>
            <li class="listen">
              <a href='<?= $m->getAudio() ?>' title='listen to <?= $m->getTitle() ?>' <?= $tracking ?>>Listen</a>
            </li>
            <?php endif ?>
            <?php endforeach ?>
          </ul>
        </td>
      </tr>
      <?php endif ?>
    </table>
  </div><!-- /.media-table -->
</div><!-- /message-series -->
